//
//  UIBarButtonItem+XMGExtension.m
//  Baisibudejie
//
//  Created by 陈成 on 2017/3/20.
//  Copyright © 2017年 yu hu. All rights reserved.
//

#import "UIBarButtonItem+XMGExtension.h"

@implementation UIBarButtonItem (XMGExtension)

+ (instancetype)itemWithTarget:(id)target image:(NSString *)image selectedImage:(NSString *)selectedImage action:(SEL)action
{
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [leftButton setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateHighlighted];
    leftButton.size = leftButton.currentImage.size;
    [leftButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[self alloc] initWithCustomView:leftButton];
}

@end
